/**
 * Copyrigth 2007 Aurelien Moreau
 * 
 * This file is part of ProcessShop.
 * 
 * ProcessShop is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * ProcessShop is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with ProcessShop; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * $Id$
 */
package net.yienyien.process.dfm.impl;

import net.yienyien.process.bpd.BPDObject;
import net.yienyien.process.bpd.Task;

import net.yienyien.process.dfm.Container;
import net.yienyien.process.dfm.DataActivity;
import net.yienyien.process.dfm.DfmPackage;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Data Activity</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link net.yienyien.process.dfm.impl.DataActivityImpl#getInputContainer <em>Input Container</em>}</li>
 *   <li>{@link net.yienyien.process.dfm.impl.DataActivityImpl#getOutputContainer <em>Output Container</em>}</li>
 *   <li>{@link net.yienyien.process.dfm.impl.DataActivityImpl#getObject <em>Object</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class DataActivityImpl extends EObjectImpl implements DataActivity {
	/**
	 * The cached value of the '{@link #getInputContainer() <em>Input Container</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getInputContainer()
	 * @generated
	 * @ordered
	 */
	protected Container inputContainer;

	/**
	 * The cached value of the '{@link #getOutputContainer() <em>Output Container</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOutputContainer()
	 * @generated
	 * @ordered
	 */
	protected Container outputContainer;

	/**
	 * The cached value of the '{@link #getObject() <em>Object</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getObject()
	 * @generated
	 * @ordered
	 */
	protected BPDObject object;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected DataActivityImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return DfmPackage.Literals.DATA_ACTIVITY;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Container getInputContainer() {
		return inputContainer;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetInputContainer(Container newInputContainer, NotificationChain msgs) {
		Container oldInputContainer = inputContainer;
		inputContainer = newInputContainer;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DfmPackage.DATA_ACTIVITY__INPUT_CONTAINER, oldInputContainer, newInputContainer);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setInputContainer(Container newInputContainer) {
		if (newInputContainer != inputContainer) {
			NotificationChain msgs = null;
			if (inputContainer != null)
				msgs = ((InternalEObject)inputContainer).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - DfmPackage.DATA_ACTIVITY__INPUT_CONTAINER, null, msgs);
			if (newInputContainer != null)
				msgs = ((InternalEObject)newInputContainer).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - DfmPackage.DATA_ACTIVITY__INPUT_CONTAINER, null, msgs);
			msgs = basicSetInputContainer(newInputContainer, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DfmPackage.DATA_ACTIVITY__INPUT_CONTAINER, newInputContainer, newInputContainer));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Container getOutputContainer() {
		return outputContainer;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetOutputContainer(Container newOutputContainer, NotificationChain msgs) {
		Container oldOutputContainer = outputContainer;
		outputContainer = newOutputContainer;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DfmPackage.DATA_ACTIVITY__OUTPUT_CONTAINER, oldOutputContainer, newOutputContainer);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setOutputContainer(Container newOutputContainer) {
		if (newOutputContainer != outputContainer) {
			NotificationChain msgs = null;
			if (outputContainer != null)
				msgs = ((InternalEObject)outputContainer).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - DfmPackage.DATA_ACTIVITY__OUTPUT_CONTAINER, null, msgs);
			if (newOutputContainer != null)
				msgs = ((InternalEObject)newOutputContainer).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - DfmPackage.DATA_ACTIVITY__OUTPUT_CONTAINER, null, msgs);
			msgs = basicSetOutputContainer(newOutputContainer, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DfmPackage.DATA_ACTIVITY__OUTPUT_CONTAINER, newOutputContainer, newOutputContainer));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public BPDObject getObject() {
		if (object != null && object.eIsProxy()) {
			InternalEObject oldObject = (InternalEObject)object;
			object = (BPDObject)eResolveProxy(oldObject);
			if (object != oldObject) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, DfmPackage.DATA_ACTIVITY__OBJECT, oldObject, object));
			}
		}
		return object;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public BPDObject basicGetObject() {
		return object;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setObject(BPDObject newObject) {
		BPDObject oldObject = object;
		object = newObject;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DfmPackage.DATA_ACTIVITY__OBJECT, oldObject, object));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case DfmPackage.DATA_ACTIVITY__INPUT_CONTAINER:
				return basicSetInputContainer(null, msgs);
			case DfmPackage.DATA_ACTIVITY__OUTPUT_CONTAINER:
				return basicSetOutputContainer(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case DfmPackage.DATA_ACTIVITY__INPUT_CONTAINER:
				return getInputContainer();
			case DfmPackage.DATA_ACTIVITY__OUTPUT_CONTAINER:
				return getOutputContainer();
			case DfmPackage.DATA_ACTIVITY__OBJECT:
				if (resolve) return getObject();
				return basicGetObject();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case DfmPackage.DATA_ACTIVITY__INPUT_CONTAINER:
				setInputContainer((Container)newValue);
				return;
			case DfmPackage.DATA_ACTIVITY__OUTPUT_CONTAINER:
				setOutputContainer((Container)newValue);
				return;
			case DfmPackage.DATA_ACTIVITY__OBJECT:
				setObject((BPDObject)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case DfmPackage.DATA_ACTIVITY__INPUT_CONTAINER:
				setInputContainer((Container)null);
				return;
			case DfmPackage.DATA_ACTIVITY__OUTPUT_CONTAINER:
				setOutputContainer((Container)null);
				return;
			case DfmPackage.DATA_ACTIVITY__OBJECT:
				setObject((BPDObject)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case DfmPackage.DATA_ACTIVITY__INPUT_CONTAINER:
				return inputContainer != null;
			case DfmPackage.DATA_ACTIVITY__OUTPUT_CONTAINER:
				return outputContainer != null;
			case DfmPackage.DATA_ACTIVITY__OBJECT:
				return object != null;
		}
		return super.eIsSet(featureID);
	}

} //DataActivityImpl
